package com.itrui.encrypted_transmission.Thread;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class TServer {
    public static void main(String[] args) throws IOException {
        //思路
        //在本机 的6666端口监听, 等待连接
        ServerSocket serverSocket = new ServerSocket(6666);
        System.out.println("服务器端，监听" + serverSocket.getLocalPort() + "端口，等待连接");
        serverSocket.getLocalPort();


        while (true){

            //当没有客户端连接6666端口时，程序会 阻塞, 等待连接
            //如果有客户端连接，则会返回Socket对象，程序继续
            Socket socket = serverSocket.accept();

            new Thread(new MyServerThread(socket)).start();
        }

//        serverSocket.close();
    }
}
